home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Mops 2.5 / Quick Edit ƒ / Subject Glossary / Floating Point < prev    next >
Encoding:
Text File  |  1992-12-12  |  4.2 KB  |  168 lines  |  [TEXT/MSET]

  1. (special note:  This description of the Mops floating point environment is
  2. incomplete.  Please refer to the Mops file floating point and the Apple
  3. Numerics Manual for detail complete information.)
  4.  
  5. GENERAL
  6.  
  7. A floating point number (flt) is input by placing a decimal point anywhere in 
  8. the number.  There is no separate stack for floats, they are accessed via 
  9. pointers on the normal stack.
  10.  
  11. All numbers to be input as floats must contain one decimal point.
  12.  
  13. The numeric base may be other than decimal when using floating point.  Floats
  14. will always be interpretted in base 10 regardless of base.  Non-floats (no
  15. decimal point) will be interpretted in the current base.
  16.  
  17. The general form for a float is as follows:
  18.  
  19. Sxxx.yyyEszz   There can be NO blanks between the components of a float.
  20.  
  21. S = optional sign of mantissa (+ or - or blank)
  22. xxx.yyy = required mantissa with required decimal  (must have xxx or yyy or both)
  23. E = optional exponent delimiter (may be e)
  24. s = optional sign of exponent
  25. zz = optional exponent, must be preceded by E
  26.  
  27. Note that local variables and named input parameters to be used for floating point
  28. numbers must have their names preceded by %.
  29.  
  30.  
  31. NUMERIC CONVERSION
  32.  
  33. FLOAT>    \ ( flt -- n )  Converts the float to an int, rounds.
  34. >FLOAT    \ ( n -- flt )  Converts the int to a float.
  35.  
  36.  
  37. MEMORY
  38.  
  39. FVALUE      flt --  : name  Fp analog of value, can use prefix operators.
  40. FCON       flt --  : name  Fp analog of constant.
  41.  
  42.  
  43.  
  44. STACK MANIPULATION
  45.  
  46.  
  47. FDUP    flt -- flt flt
  48. FOVER     flt1 flt2 -- flt1 flt2 flt1
  49. F2DUP     flt1 flt2 -- flt1 flt2
  50. FDROP     flt --
  51. F2DROP     flt1 flt2 --
  52.  
  53. \        ========= Dyadic comparisons ==========
  54. Stack frame for all dyadic comparisons: ( flt1 flt2 -- b )
  55. F> 
  56. F< 
  57. F≥ 
  58. F≤ 
  59. F=
  60. F≠
  61.  
  62. \        ========= Monadic comparisons ==========
  63. Stack frame for all monadic comparisons: ( flt -- b )
  64.  
  65. F0= 
  66. F0≠ 
  67. F0≥ 
  68. F0< 
  69. F0≤ 
  70. F0> 
  71.  
  72. \    =============== Arithmetic operators ==============
  73.  
  74. \ ( flt1 flt2 -- flt1<op>flt2 )  Result gets stored in flt1's data.
  75.  
  76. F+
  77. F- 
  78. F*
  79. F/
  80.  
  81. PREFIX OPERATORS   Use for fvalues, local fvariables, named input parameters.
  82.  
  83. ->    flt --  : word    Gazinta.  Stores flt.
  84. ++>    flt --  : word    Adds flt.
  85. -->    flt --  : word    Subtracts flt.
  86. NEG>    --  : word    Negates.
  87.  
  88. *>    flt --  : word    Multiplies by flt.
  89. />    flt --  : word    Divides by flt.
  90. ABS>    --  : word    Changes to absolute value.
  91.  
  92.  
  93. \        ============= Monadic operations ==============
  94.  
  95. \ FNEGATE and FABS simply operate on the sign bit, so we don't need to call 
  96. SANE at all.  The SANE manual actually recommends this.  
  97.  
  98. FNEGATE 
  99. FABS 
  100. SQRT 
  101. ROUND 
  102. TRUNC 
  103.  
  104.  
  105.  
  106. \        ===================================
  107. \           FP to/from decimal conversion
  108. \        ===================================
  109.  
  110. E.R  ( flt wid -- )  Prints the floating point number in scientific notation
  111. in a field wid characters wide.
  112.     wide
  113. E.      ( flt -- )  \ same as 26 e.r
  114. F.R  ( flt wid -- )  Prints the floating point number without exponents in a 
  115.     field wid characters wide.
  116. FCONV?  { addr len -- flt T  |  -- F }
  117.         \ Converts the passed-in ASCII string to
  118.         \ floating, if possible.  I like this name better
  119.         \ than ATOF which Neon had, but change it back if
  120.         \ you want to.
  121.  
  122. \        =================================
  123. \                  Transcendentals
  124. \        =================================
  125.  
  126. LN        \ Natural log 
  127. LOG2        \ Base 2 log 
  128. LN1        \ ln(1+x) 
  129. LOG21        \ log2(1+x).  I don't think LOG21 is a very helpful name (pure
  130.             \  computerese), but I guess we're  stuck with it. 
  131. EXP        \ Base e exponential 
  132. EXP2        \ Base 2 exponential 
  133. EXP1        \ e**x - 1 
  134. EXP21    \ 2**x - 1 
  135. **N    \ ( x n -- x**n )  Integer exponentiation.  This wasn't
  136.         \  in Neon, but might be useful.  Note this operation
  137.         \  ignores the high-order 16 bits of n. 
  138. F**    \ ( x y -- x**y )  General exponentiation - takes 2 floats.
  139.         \  Here I think the Neon name was crazy.  But we've still
  140.         \  got it below for compatibility.
  141.  
  142. \ Trig functions.
  143.  
  144. DEG2RAD    \ ( deg -- rad )  Converts degrees to radians 
  145. RAD2DEG    \ ( rad -- deg )  Converts radians to degrees 
  146.  
  147. The following require radians as input.
  148. SIN
  149. COS
  150. TAN 
  151. ARCTAN
  152. COT        \ ( x -- cot(x) )  Cotangent of x 
  153.  
  154. FRAND    \ floating-pt random number routine 
  155.  
  156. \        ======================================
  157. \             Sundry useful constants and operations
  158. \        ======================================
  159. 1.0 exp        fcon    E
  160. 10.0 ln        fcon    LN(10)
  161. PI
  162. UNDEF    \ Ditto
  163.  
  164. 1/X 
  165. LOG        \ ( x -- log(x) )  Log base 10 of x 
  166. ANTILOG    \ ( x -- antilog(x) )  Antilog ( 10^x ) of x 
  167.  
  168.